#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <string>

using namespace std;

#define IPV4 	0
#define IPV6 	1

namespace NM
{
class 	Saddr
{
public:
    Saddr();											/**< Default constructor. */
    Saddr(int);                                         /**< Specify the domain (== family) type. */
    Saddr(const Saddr &);								/**< Construct by copy. */
    Saddr &operator=(const Saddr &);					/**< Assignment operator. */

    void 				setDomain(int);					/**< Set domain (== family) type. */
    void 				setPort(int);					/**< Set port. */
    void 				setAddress(const string &);		/**< Set IP address manually. */
    const string 		&getAddress();					/**< Return the IP address in a human-readable form. */
    void 				setName(const string &);		/**< Set IP address or hostname. */
    int 				getDomain();					/**< Return domain (== family) type. */
    int 				getPort();						/**< Return port. */
    struct sockaddr 	*getSaddr();					/**< Return a pointer on the internal structure. */
    int 				getSaddrSize();					/**< Return the size of the internal structure. */

private:
    int 					type;						/**< IPV4 or IPV6. */
    struct sockaddr_in 		addr4;						/**< IPV4 internal structure. */
    struct sockaddr_in6		addr6;						/**< IPV6 internal structure. */
    string 					address;					/**< User-friendly IP address container. */
};
}
